package com.example.orderflow.controller;

import java.util.List;

import com.example.orderflow.controller.base.ABaseController;
import com.example.orderflow.entity.query.ApproveHistoryQuery;
import com.example.orderflow.entity.po.ApproveHistory;
import com.example.orderflow.entity.vo.ResponseVO;
import com.example.orderflow.service.ApproveHistoryService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 *  Controller
 */
@RestController("approveHistoryController")
@RequestMapping("/approveHistory")
public class ApproveHistoryController extends ABaseController {

	@Resource
	private ApproveHistoryService approveHistoryService;
	/**
	 * 根据条件分页查询
	 */
	@RequestMapping("/loadDataList")
	public ResponseVO loadDataList(ApproveHistoryQuery query){
		return getSuccessResponseVO(approveHistoryService.findListByPage(query));
	}

	/**
	 * 新增
	 */
	@RequestMapping("/add")
	public ResponseVO add(ApproveHistory bean) {
		approveHistoryService.add(bean);
		return getSuccessResponseVO(null);
	}

	/**
	 * 批量新增
	 */
	@RequestMapping("/addBatch")
	public ResponseVO addBatch(@RequestBody List<ApproveHistory> listBean) {
		approveHistoryService.addBatch(listBean);
		return getSuccessResponseVO(null);
	}

	/**
	 * 批量新增/修改
	 */
	@RequestMapping("/addOrUpdateBatch")
	public ResponseVO addOrUpdateBatch(@RequestBody List<ApproveHistory> listBean) {
		approveHistoryService.addBatch(listBean);
		return getSuccessResponseVO(null);
	}

	/**
	 * 根据Id查询对象
	 */
	@RequestMapping("/getApproveHistoryById")
	public ResponseVO getApproveHistoryById(Integer id) {
		return getSuccessResponseVO(approveHistoryService.getApproveHistoryById(id));
	}

	/**
	 * 根据Id修改对象
	 */
	@RequestMapping("/updateApproveHistoryById")
	public ResponseVO updateApproveHistoryById(ApproveHistory bean,Integer id) {
		approveHistoryService.updateApproveHistoryById(bean,id);
		return getSuccessResponseVO(null);
	}

	/**
	 * 根据Id删除
	 */
	@RequestMapping("/deleteApproveHistoryById")
	public ResponseVO deleteApproveHistoryById(Integer id) {
		approveHistoryService.deleteApproveHistoryById(id);
		return getSuccessResponseVO(null);
	}
}